package com.lzx.iteam;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import com.lzx.iteam.R;
import com.lzx.iteam.adapter.ContactGroupAdapter;

import java.util.ArrayList;

/**
 * Created by zhangshuai on 15-4-23.
 * 分组信息
 * 进入页面时要传以下参数
 * group.putExtra(ContactGroupDetailActivity.CONTACT_NAME, mCloudContactName);
 group.putStringArrayListExtra(ContactGroupDetailActivity.CONTACT_GROUPS, mCloudTags);
 */
public class ContactGroupDetailActivity extends Activity implements View.OnClickListener{

    public static final String CONTACT_NAME = "contact_name";
    public static final String CONTACT_GROUPS = "contact_groups";

    private LinearLayout mBack;
    private TextView mGroupTitle;
    private ListView mLvTags;
    private View top,bottom;

    private String mName;
    private ArrayList<String> mGroups;
    private ContactGroupAdapter mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.contact_group_detail_layout);
        initView();
        getData();
        setData();

    }

    public void getData(){
        mName = getIntent().getStringExtra(CONTACT_NAME);
        mGroups = getIntent().getStringArrayListExtra(CONTACT_GROUPS);
        if(mGroups.size() == 0){
            top.setVisibility(View.GONE);
            bottom.setVisibility(View.GONE);
        }


    }
    public void setData(){
        mGroupTitle.setText(getString(R.string.contact_group_title,mName));
        mAdapter = new ContactGroupAdapter(this,mGroups);
        mLvTags.setAdapter(mAdapter);
    }

    public void initView(){
        mBack = (LinearLayout) findViewById(R.id.group_ll_back);
        mBack.setOnClickListener(this);
        mGroupTitle = (TextView) findViewById(R.id.contact_group_tv);
        mLvTags = (ListView) findViewById(R.id.contact_tags_lv);
        top = findViewById(R.id.group_top_view);
        bottom = findViewById(R.id.group_bottom_view);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.group_ll_back:
                finish();
                break;
        }
    }
}
